<?php
$section = "newsletter";
$titre = _LB_NEWSLETTER;
$link = $section;
Session::setBackLink($link);
//create cfer
$cfer = new Cfer(array(
	_LB_HOME => APPLICATION_URL_FO,
    _LB_NEWSLETTER => APPLICATION_URL_FO."/newsletter/"
));
$email = Request::get('email');
$sent = Request::get('sent');
if($email != "" && checkEmailValide($email)){
    $newsletter = new Newsletter();
    $newsletter->EMAIL = $email;
    @$newsletter->insert();
    redirect(APPLICATION_URL_FO."/newsletter/?sent=true");
}

$page = new Static_Page();

if($sent == "true"){
    $page->query("SELECT * FROM STATIC_PAGE WHERE CODE = 'newsletter_thankpage'");
}
else{
    $page->query("SELECT * FROM STATIC_PAGE WHERE CODE = 'newsletter'");
}

$page->fetch();

$bsLeft = Business_Solution::getSubItem(0);
Session::setBackCfer($link, $cfer->getCferArray());
$smarty->assign('cfer', $cfer);
$smarty->assign('page', $page);
$smarty->assign('bsLeft', $bsLeft);
$smarty->assign('sent', $sent);
$smarty->assign('titre', $titre);
$smarty->display("newsletter.html");